package org.example.chatroom.common.pojo.response;

import lombok.Data;
import org.example.chatroom.common.emums.ResultCodeEmum;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2025-06-21
 * Time: 14:35
 */
@Data
public class Result {
    //状态
    //错误信息
    //正确数据
    private ResultCodeEmum code;
    private String errMsg;
    private Object data;

    //静态方法(成功)
    public static Result success(Object data){
        Result result = new Result();
        result.setCode(ResultCodeEmum.SUCCESS);
        result.setData(data);
        return result;
    }
    //静态方法(失败)
    public static Result fail(String err){
        Result result = new Result();
        result.setCode(ResultCodeEmum.FAIL);
        result.setErrMsg(err);
        return result;
    }
}
